<script setup lang="ts">
import {ref} from "vue";

let todoText = ref('');
let emit = defineEmits(['addTask'])
function onAddClick(){
  emit("addTask", todoText.value);
  todoText.value='';
}

</script>

<template>
  <div class="input-row">
    <el-input style="width: 20em" placeholder="请输入一个待办事项..." v-model="todoText" />

    <!--      //控件（主件）-->
    <el-button type="success" @click="onAddClick()">添加</el-button>
    <!--      @符号表明一个约定，后面是一个事件名称,指定一个函数名-->
    <!--      //success代表的按钮的颜色-->
  </div>
</template>

<style scoped>
.input-row {
  display: flex;
  justify-content: center;
  margin-top: 20px;
  gap: 0.5em;
}
</style>